<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>item</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <script src="/js/jquery-2.2.3.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/bootstrap/bootstrap.min.css"/>
    <style type="text/css">
        .coldiv{ margin:5px 0px; }
    </style>
    <script type="text/javascript">   
		
	</script>    
 
</head>

<body>
<div class="container">
    <div class="row">
        <div class="col-md-12 coldiv"  style="font-size:16px">
                        商品名称:<span style="color:red;font-size:16px">捷波朗JabraBOOST劲步商务通话蓝牙耳机通用型耳挂式 黑色</span><br><br>           
                        商品价格:<span style="color:red;">￥169.00</span><br><br>
                        商品数量:<input type="text" id="number" value="2"><br><br>
                  <input type="hidden" id="itemId" value="${itemId}">
           <input type="button" id="btn" value="加入购物车"><br><br>
           <script type="text/javascript">   
           $("#btn").click(function(){
        	    //准备数据
		    	var itemId=$("#itemId").val();
		    	var num=$("#number").val();
		    	var url="http://localhost:8080/cart/create?itemId="+itemId+"&num="+num
		    	//发送ajax添加购物车
		    	$.ajax({
		            async:true,//异步
		            type:"post",
		            data:{
		            },
		            url:url,
		            beforeSend:function(){
		            	console.log(url);
		            	if(num=="0"){
		            		return false;
		            	}
		            },
		            success:function(r){
		                if(r.status==200){
		                	alert("亲~,购物车添加成功")
		                }
		            	
		            }
		        })
		       
		    })
	       </script>
        </div>
    </div>
</div>  
</body>

</html>